﻿<UserControl x:Class="NthDownload.Views.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
             xmlns:cal="http://www.caliburnproject.org">
    <Grid Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState Name="SettingsVisible">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="SettingsMenu" Duration="0">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>                    
                </VisualState>
                <VisualState Name="SettingsHidden">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="SettingsMenu" Duration="0">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>                        
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        
        <i:Interaction.Triggers>
            <ei:DataTrigger Binding="{Binding IsSettingsVisible}" Value="True">
                <ei:GoToStateAction StateName="SettingsVisible" />
            </ei:DataTrigger>
            <ei:DataTrigger Binding="{Binding IsSettingsVisible}" Value="False">
                <ei:GoToStateAction StateName="SettingsHidden" />
            </ei:DataTrigger>
        </i:Interaction.Triggers>
        
        <Grid.RowDefinitions>
            <RowDefinition Name="HeaderRow" Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <StackPanel Orientation="Horizontal" Grid.Row="0" Margin="0,0,0,5" HorizontalAlignment="Left">
            <Button Name="ShowDownloads" Content="Downloads" Margin="0,0,5,0" />
            <Button Name="ShowBandwidthProviders" Content="Bandwidth Providers" Margin="0,0,5,0" />
        </StackPanel>

        <ContentControl x:Name="ActiveItem" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                        Grid.Row="1"/>

        <Border Name="SettingsMenu" MinWidth="80" Grid.RowSpan="2" HorizontalAlignment="Right" Background="White" Visibility="Collapsed" BorderBrush="Black" BorderThickness="1,0,0,0">
            <StackPanel>
                <Border Height="30" />
                <ItemsControl ItemsSource="{Binding DownloadPluginsWithSettings}" >
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <!--<Button Content="{Binding DisplayName}" Height="150" Width="150" Margin="2.5,0,2.5,0" Style="{StaticResource PluginSelector}"
                                cal:Message.Attach="[Event Click] = [Action Select($dataContext)]"/>-->
                            <Button Content="{Binding DisplayName}" HorizontalAlignment="Right" Margin="5,5,0,0" 
                                    cal:Message.Attach="[Event Click] = [Action ShowPluginSettings($dataContext)]"/>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </Border>        
        
        <StackPanel Orientation="Horizontal" Grid.Row="0" Margin="0,0,0,5" HorizontalAlignment="Right">
            <Button Name="ToggleSettingsMenu" Content="Settings" Margin="5,0,0,0" />
        </StackPanel>
    </Grid>
</UserControl>
